﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace ToolHelp
{
    /// <summary>
    /// Json帮助类
    /// </summary>
    public static class JsonHelper
    {
        public static string ToJson(this object obj)
        {
            var jsonStr = JsonConvert.SerializeObject(obj, Formatting.None);
            return jsonStr;
        }
        public static T ToObject<T>(this string stringValue) where T : class 
        { 
           var obj = JsonConvert.DeserializeObject<T>(stringValue);
            return obj;
        }
    }
}
